package com.aldobucchi.x.flash.net.URLRequest
{
	import flash.net.URLRequest;
	
	import com.adobe.net.URI;
	
	public class HTTPMethodTunnelingUtil
	{
	
		/**
		 * Makes the necessary changes to adapt the request for Restlet Tunneling.
		 * 
		 * Remember to add something to the URLRequest.data property. otherwise some browsers
		 * will fallback from POST ( used for tunneling ) to GET
		 * 
		 * @param request
		 * @param method
		 * @param parameterName
		 * 
		 */		 
		public static function setTunneledMethod( request:URLRequest, method:String, parameterName:String = "method" ):void
		{
			request.method = "POST";
			var uri:URI = new URI( request.url );
			uri.setQueryValue( parameterName , method );						
			request.url = uri.toString();
		}
	
	
	}
	
}